/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.infinityk.tangentgenerator;

/**
 *
 * @author Asier
 */
public class Vec3 {
    public double x,y,z;

    public Vec3() {
    }

    public Vec3(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public void sum(Vec3 b){
        x += b.x;
        y += b.y;
        z += b.z;
    }

    public void minus(Vec3 b){
        x -= b.x;
        y -= b.y;
        z -= b.z;
    }

    public void mult(double s){
        x *= s;
        y *= s;
        z *= s;
    }

    public Vec3 copy(){
        return new Vec3(x, y, z);
    }

    public double dot(Vec3 b){
        return x*b.x + y*b.y + z*b.z;
    }

    public double length(){
        return Math.sqrt(x*x + y*y + z*z);
    }

    public void normalize(){
        double l = length();
        x /= l;
        y /= l;
        z /= l;
    }

}
